#pragma once

#include <iostream>
#include <vector>
#include <ctime>
using namespace std;

typedef void (*task_t)();

void PrintLog()
{
    cout << "我是一个打印日志的任务" << endl;
}

void DownLoad()
{
    cout << "我是一个下载的任务" << endl;
}

void UpLoad()
{
    cout << "我是一个上传的任务" << endl;
}

class TaskManager
{
public:
    TaskManager()
    {
        srand((unsigned int)time(nullptr));
    }

    ~TaskManager()
    {

    }

    void Register(task_t t)
    {
        _tasks.push_back(t);
    }

    int Code()
    {
        return rand() % _tasks.size();
    }

    void Execute(int code)
    {
        if(code >= 0 && code < _tasks.size())
        {
            _tasks[code]();
        }
    }

private:
    vector<task_t> _tasks;
};